using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
using DTO;

namespace QLSV
{
    public partial class ThemDSKhoa : Form
    {
        KHOA khoa = new KHOA();
        KhoaDAL khoadal = new KhoaDAL();
        public ThemDSKhoa()
        {
            InitializeComponent();
            lblThongbao.Text = "Nhap ma cua khoa can them , roi nhap nut Them";
            btnThem.Enabled = true;
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                bool khoa = khoadal.InsertKHOA(Convert.ToByte(txtMakhoa.Text), txtTenkhoa.Text);
                if (khoa)
                {
                    lblThongbao.Text = "Them thanh cong";
                    btnThem.Enabled = false;
                    btnUndo.Enabled = true;

                }
                else
                    lblThongbao.Text = "Them that bai";
            }
            catch
            {
                lblThongbao.Text = "Them that bai";
            }

        }

        private void btnUndo_Click(object sender, EventArgs e)
        {
            lblThongbao.Text = "Nhap ma cua mon hoc can thay doi thong tin, roi nhap nut Them";
            txtTenkhoa.Text = "";
            txtMakhoa.Text = "";
            btnThem.Enabled = true;
            btnUndo.Enabled = false;
        }
    }
}